Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(konnect): fix reconciling entities when they got created on Konnect but an error was returned #716

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

pmalek
Copy link
Member

@pmalek pmalek commented Oct 8, 2024

What this PR does / why we need it:

This PR fixes an issue where a Create() operation in generic reconciler would result in creating an entity (thus getting an ID) but returning an error for some reason (e.g. when KonnectGatewayControlPlane group has some of its members missing or lacking Programmed=True status condition).

This changes the order of actions after creation to:

  • if err == nil assign URL and Org ID from APIAuthConfiguration
  • patch the status to include any changes that were performed in Create
  • if an ID was assigned in Create() (an object was created) add the finalizer to the object so that its deleted from Konnect on deletion in cluster.

This also adds 1 index for KonnectGatewayControlPlane for indexing on the group members.

Tested with

while true ; do kubectl apply -f groups.yaml && \
  kubectl wait --for=condition=Programmed=true --timeout=5s konnectgatewaycontrolplane test1 group1 && \
kubectl delete --ignore-not-found konnectgatewaycontrolplanes.konnect.konghq.com group1 test1; done

With groups.yaml being:

kind: KonnectGatewayControlPlane
apiVersion: konnect.konghq.com/v1alpha1
metadata:
  name: test1
  namespace: default
spec:
  name: test1
  konnect:
    authRef:
      name: konnect-api-auth-dev-1
---
kind: KonnectGatewayControlPlane
apiVersion: konnect.konghq.com/v1alpha1
metadata:
  name: test2
  namespace: default
spec:
  name: test2
  konnect:
    authRef:
      name: konnect-api-auth-dev-1
---
kind: KonnectGatewayControlPlane
apiVersion: konnect.konghq.com/v1alpha1
metadata:
  name: test3
  namespace: default
spec:
  name: test3
  konnect:
    authRef:
      name: konnect-api-auth-dev-1
---
kind: KonnectGatewayControlPlane
apiVersion: konnect.konghq.com/v1alpha1
metadata:
  name: group1
  namespace: default
spec:
  name: group1
  cluster_type: CLUSTER_TYPE_CONTROL_PLANE_GROUP
  members:
  - name: test1
  - name: test2
  - name: test3
  labels:
    app: group1
    key1: group1
  konnect:
    authRef:
      name: konnect-api-auth-dev-1

@pmalek pmalek added this to the KGO v1.4.x milestone Oct 8, 2024
@pmalek pmalek self-assigned this Oct 8, 2024
@pmalek pmalek force-pushed the fix-konnectcontrolplane-group-membership branch from 8569670 to 292fc6a Compare October 8, 2024 13:58
@pmalek pmalek marked this pull request as ready for review October 8, 2024 14:15
@pmalek pmalek requested a review from a team as a code owner October 8, 2024 14:15
@pmalek pmalek force-pushed the fix-konnectcontrolplane-group-membership branch 5 times, most recently from 7dc0797 to 21ffa8d Compare October 9, 2024 08:01
@pmalek pmalek force-pushed the fix-konnectcontrolplane-group-membership branch from 21ffa8d to 65aa40e Compare October 9, 2024 08:17
@pmalek pmalek merged commit 742b401 into main Oct 10, 2024
21 checks passed
@pmalek pmalek deleted the fix-konnectcontrolplane-group-membership branch October 10, 2024 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants